<template>
    <div>
        <x-header :left-options="{showBack: false}" class="head">
            免费WIFI列表({{this.$store.getters.getSellerName}})
            </x-header>
        <div class="main">
            <div class="info" v-for="(item,index) in WifiList" :key="index">
                <p>wifi名称：{{item.mingc}}</p>
                <p>wifi密码：
                    <x-button mini plain type="primary" v-clipboard:copy="item.mim" v-clipboard:success="onCopy" v-clipboard:error="onError">复制密码</x-button>
                </p>
                <p>备注信息：{{item.beiz}}</p>
            </div>
        </div>
    </div>
</template>
<script>
import { sign, signStr } from "@/assets/js/sign.js";
import { XButton, XHeader } from "vux";
export default {
  components: {
    XButton,
    XHeader
  },
  data() {
    return {
      WifiList: null
    };
  },
  methods: {
    init(sjid) {
      let param = sign("/v1/api/GetWifi");
      param.append("sjid", sjid);
      this.$http
        .post("/GetWifi", param)
        .then(ret => {
          if (ret.status == 200) {
            var _data = ret.data.resultObject;
            var _code = ret.data.code;
            var _msg = ret.data.msg;

            if (_code == 1) {
              this.WifiList = _data;
            }
          }
        })
        .catch((err = {}));
    },
    onCopy() {
      this.$vux.toast.text("密码复制成功", "top");
    },
    onError() {
      this.$vux.toast.text("密码复制失败", "top");
    }
  },
  created() {
    let sjid = this.$store.getters.getSellerId;
    this.init(sjid);
  },
  activated() {
    this.$emit("viewIn", "wifi");
  }
};
</script>
<style scoped>
.main {
  padding: 10px;
}

.info {
  font-size: 16px;
  padding: 20px;
  border-bottom: 1px solid #ccc;
}
.head{
    background-color: #ffa500
}
</style>
